<?php
namespace Baoming\Controller;
use Common\Controller\Base;
class IndexController extends Base {
    private $Baoming = NULL;
    private $SignUp = NULL;
    protected function _initialize() {
        parent::_initialize();
        $this->Baoming= D('Baoming/Baoming');
        $this->SignUp = D('Baoming/SignUp');
    }
    public function index() {
        //条件
        $where = array();
        $keyword = I('get.keyword');
        if ($keyword) {
            $where['zhiwei'] = array('LIKE', "%{$keyword}%");
            $this->assign('keyword', $keyword);
        }

        $count = $this->Baoming->where($where)->count();
        $page = $this->page($count, 20);
        $data = $this->Baoming->where($where)->limit($page->firstRow . ',' . $page->listRows)->order(array("id" => "DESC"))->select();

        $this->assign('list', $data);
        $this->assign("Page", $page->show());
        $this->assign('count', $count);
        $this->display();
    }
    public function addBaoming() {
        if (IS_POST) {
            $post = I('post.', NULL, 'htmlspecialchars');
            if ($this->SignUp->addCandidates($post)) {
                $this->success('你的报名信息已经成功提交！', U('Index/index'));
            } else {
                $error = $this->SignUp->getError();
                $this->error($error ? $error : '提交失败！');
            }
        } else {
           
        }
    }

}
